package Array;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

/**
 * @auther wangchenghao
 * @date 2021/6/3
 * 存在重复元素
 **/
public class test4 {
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> set=new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])){
                return true;
            }else {
                set.add(nums[i]);
            }
        }
        return false;
    }
}
